<template>
	<div class="searchlist">
		<van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="getlist">
			<artlist :list="list"></artlist>
			<van-cell v-for="item in list" :key="item" :title="item" />
		</van-list>
	</div>
</template>

<script>
	import searchView from '@/views/search/SearchView'
	import {
		search
	} from '@/api/search';
	import artlist from '@/views/home/HeadView.vue'
	export default {
		name: 'SearchListView',
		components: {
			artlist,
		},
		data() {
			return {
				skip: 0,
				limit: 10,
				list: [],
				loading: false,
				finished: false,
			}
		},
		computed: {
			key_word() {
				return this.$route.query.key_word
			}
		},
		created() {
			this.getlist()
		},
		methods: {
			getlist() {
				let {
					skip,
					limit,
					key_word
				} = this
				search({
					skip,
					limit,
					key_word
				}).then(res => {
					if (res.code === 0) {
						this.list.push(...res.data);
						
						let len = this.list.length;
						
						if(len>=res.count){
							this.finished = true
						}
						
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
